<%@ page language="java" contentType="text/html;UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.bear.model.entity.User" %>
<%@include file="../base.jsp" %>

<title>用户信息</title>
<script>
function toUserlist(pageNumber)
{
	$("#page").val(pageNumber);
	$("#touserinfo").submit();
}

function addfriend(id)
{

	$.post("<c:url value="/userInfo/addfriend.html"/>","id="+id,function(data,statusText)
			{
				$.messager.show({
					title:'My Title',
					msg:data,
					showType:'show'
				});
				
			},"html");
	
}

function sayhi(id)
{

	$.post("<c:url value="/userInfo/sayhi.html"/>","id="+id,function(data,statusText)
			{
				$.messager.show({
					title:'My Title',
					msg:data,
					showType:'show'
				});
				
			},"html");
	
}
</script>

</head>



<style type="text/css">
		label{
			width:120px;
			display:block;
		}
</style>

<body>
<img src="<c:url value="/ico/egg.jpg"/>" height="50"><font class="thick">看看都有谁</font><br>
	

	
<%
	User u=(User)request.getAttribute("user");
	if(u!=null)
	{
		out.print("<font color='red'>"+u.getUsername()+"欢迎回来，您的积分是"+u.getCredit()+"</font>");
	}
	User u2 = (User)session.getAttribute("user");
%>

<div class="demo-info">
	<div class="demo-tip icon-tip"></div>
	<div>看看这里都有谁，喝杯白酒，交个朋友！</div>
</div>		
<a href="<c:url value="/App.html"/>" class="easyui-linkbutton" >首页</a>
<%
if(u2!=null)
{
%>
<a href="<c:url value="/userInfo/mydata.html"/>" class="easyui-linkbutton" >我的资料</a>
<a href="<c:url value="/userInfo/myfriends.html"/>" class="easyui-linkbutton" >我的好友</a>
<a href="<c:url value="/userInfo/mymessage.html"/>" class="easyui-linkbutton" >我的消息</a><br>
<%
}
%>

<%List<User> users = (List<User>)request.getAttribute("users"); 
	Long count = (Long)request.getAttribute("count");
	Integer pageNo = (Integer)request.getAttribute("pageNo");
%>
<%
for(User u3:users){
	String address = u3.getPhotoAddress();
	String name = u3.getUsername();
	String sign = u3.getSign();
	Integer u3id = u3.getId();
%>
<table>
	<tr>
	<td rowspan="3"><img 
<%
if(address==null){ 
%>	
src="<c:url value="/ico/head.jpg"/>" 
<%}
else{ %> 
src="<c:url value="<%=address %>"/>" 
<%} %>
height="150"></td>
	<td>用户名：</td><td><%=name %></td>
	<td><a href="javascript:addfriend(<%=u3id %>)" class="easyui-linkbutton" data-options="iconCls:'icon-add'">加为好友</a><br>
	<a href="javascript:sayhi(<%=u3id %>)" class="easyui-linkbutton" data-options="iconCls:'icon-back'">打个招呼</a>
	</td>
	</tr>
	<tr>
	<td rowspan="2">个性签名：</td><td><%=sign %></td>
	</tr>
</table>
<%}
	
%>



<div id="pp" class="easyui-pagination" style="background:#efefef;border:1px solid #ccc;"
			data-options="
				total:<%=count %>,
				pageSize: 5,
        		pageList: [5],
        		pageNumber:<%=pageNo %>,
       			beforePageText: '第',
        		afterPageText: '页    共 {pages} 页', 
        		displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
				onSelectPage:function(pageNumber, pageSize){
					$(this).pagination('loading');
					//alert('pageNumber:'+pageNumber+',pageSize:'+pageSize);
					toUserlist(pageNumber);
					$(this).pagination('loaded');
				}
			">
	</div>
<form id="touserinfo" action="<c:url value="/userInfo.html"/>">
<input id="page" type="hidden" name="page" value="-1"></input>
</form>
	
<%@include file="../botton.jsp" %>
</body>
</html>